package org.gdpu.service.impl;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.gdpu.base.DaoSupport;
import org.gdpu.model.Teams;
import org.gdpu.service.TeamsService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import javax.persistence.Query;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by HEWI2 on 1/13/14.
 */
@Service
@Transactional
public class TeamsServiceImpl extends DaoSupport<Teams> implements TeamsService {

    @Override
    public List<Teams> allTeams() {
        Query query = em.createQuery("from Teams t");
        return query.getResultList();
    }

    @Override
    public Teams findByName(String name) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("teamName", name);
        return (Teams) this.findSpecialObject(Teams.class, params);
    }
}
